package com.nf;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.Connection;
import java.sql.DriverManager;


public class App3 {



    public static void main( String[] args ) throws Exception{
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");


        //获取数据库连接，只用了2行代码
        ComboPooledDataSource pool = (ComboPooledDataSource)ac.getBean("xxxx");
        long start_time = System.currentTimeMillis();
        for (int i=0;i<1000;i++) {
            Connection c1 = pool.getConnection();
            Connection c2 = pool.getConnection();
            Connection c3 = pool.getConnection();
            c1.close();
            c2.close();
            c3.close();
        }
        long end_time = System.currentTimeMillis();
        System.out.println("耗时："+ (end_time-start_time) +"毫秒");






    }
}
